package site.zhouinfo.designpattern.guanchazhemoshi.jdk;

import java.util.Observable;
import java.util.Observer;

/**
 * @author zhou
 * @create 2017-04-06 18:55
 * @email zhouinfo@qq.com
 */
public class JdkReader implements Observer {

    private String name;

    public JdkReader() {

    }

    public JdkReader(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void update(Observable o, Object obj) {
        //这是采用推的方式
        System.out.println(name + "收到报纸了，阅读先。目标推过来的内容是===" + obj);
        //这是获取拉的数据
        System.out.println(name + "收到报纸了，阅读先。主动到目标对象去拉的内容是===" + ((JdkNewsPaper) o).getContent());
    }
}
